#------------------------------------------------------------------------------
# Project:     Multi-Programmer Game Demo
# Name:        lifeBar.py
# Purpose:     Health counter Object
# 
# Authors:     Bailey Robinson, Calvin Berger, Alyissa Jackson
# Main Author: Alyissa
#
# Created:     11/30/2012
# Copyright:   (c) Chris Spooner 2012
# Licence:     New BSD
#------------------------------------------------------------------------------
import pygame, math, sys, random

class LifeBar():
    def __init__(self, maxHealth, position):
        surfaces = []
        self.surfaces = []
        surfaces += [pygame.image.load("rsc/LIFEBAR1.PNG")]
        surfaces += [pygame.image.load("rsc/LIFEBAR3.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR4.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR5.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR6.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR8.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR9.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR10.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR11.png")]
        surfaces += [pygame.image.load("rsc/LIFEBAR12.png")]
        
        
        for surf in surfaces:
            surf = pygame.transform.scale(surf, (160,50))
            self.surfaces += [surf]
        self.maxFrame = len(self.surfaces)-1
        self.frame = 0
        self.minFrame = 0
        self.surface = self.surfaces[self.frame]
        self.rect = self.surface.get_rect()
        self.health = maxHealth
        self.maxHealth = maxHealth
        self.place(position)
            
    def  __str__(self):
        return "I'm a lifebar " + str(self.rect.center) + str(self.health)
        
     
    def place(self, position):
        #print "I've moved to", position;
        pass
        
        
    def update(self, man):
       #print man.life
       if man.life == 100:
            self.surface = self.surfaces[0]
       elif man.life >= 90:
            self.surface = self.surfaces[1]
       elif man.life >= 80:
            self.surface = self.surfaces[2]
       elif man.life >= 70:
            self.surface = self.surfaces[3]
       elif man.life >= 60:
            self.surface = self.surfaces[4]
       elif man.life >= 50:
            self.surface = self.surfaces[5]
       elif man.life >= 40:
            self.surface = self.surfaces[6]
       elif man.life >= 30:
            self.surface = self.surfaces[7]
       elif man.life >= 20:
            self.surface = self.surfaces[8]
       elif man.life >= 10:
            self.surface = self.surfaces[9]
            
       print "My life is" + str(man.life);
       
        
    
    def heal(self, man):
        if man.life >= 10:
            self.surface = self.surfaces[9]
        elif man.life >= 20:
            self.surface = self.surfaces[8]
        elif man.life >= 30:
            self.surface = self.surfaces[7]
        elif man.life >= 40:
            self.surface = self.surfaces[6]
        elif man.life >= 50:
            self.surface = self.surfaces[5]
        elif man.life >= 60:
            self.surface = self.surfaces[4]
        elif man.life >= 70:
            self.surface = self.surfaces[3]
        elif man.life >= 80:
            self.surface = self.surfaces[2]
        elif man.life >= 90:
            self.surface = self.surfaces[1]
        elif man.life == 100:
            self.surface = self.surfaces[0]
            
        print "I'm healed by" + str(amount);
        